<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
  <th:block th:include="include :: header('部门列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
  <div class="row">
    <div class="btn-group-sm" id="toolbar" role="group">
      <a class="btn btn-success" onclick="$.operate.add(1)" >
        <i class="fa fa-plus"></i> 新增
      </a>
      <a class="btn btn-info" id="expandAllBtn">
        <i class="fa fa-exchange"></i> 展开/折叠
      </a>
    </div>
    <div class="col-sm-12 select-table table-striped">
      <table id="bootstrap-tree-table"></table>
    </div>
  </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">

  var prefix = "/skgoods"
  $(function() {
    var options = {
      code: "categoryId",
      parentCode: "parentId",
      uniqueId: "recordId",
      url:prefix + "/skGoodsList",
      createUrl:prefix + "/add",
      updateUrl:prefix + "/edit/{id}",
      removeUrl:prefix + "/delete/{id}",
      modalName:"商品列表",
      columns: [
        {
          field: 'id',
          title: 'id',
          align: "left"
        },
        {
          field: 'goodsName',
          title: '产品名称',
          align: "left"
        },
        {
          field: 'goodsTitle',
          title: '商品类型',
          align: "left"
        },
        // {
        //   field: 'goodsImg',
        //   title: '图片',
        //   align: "left"
        // },
        {
          field: 'goodsDetail',
          title: '商品明细',
          align: "left"
        },
        {
          field: 'goodsPrice',
          title: '价格',
          align: "left"
        },
        {
          field: 'goodsStock',
          title: '商品库存',
          align: "left",
        },
        {
          title: '操作',
          align: 'left',
          formatter: function(value, row, index) {
            if (row.parentId != 0) {
              var actions = [];
              actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
             console.log(row.id);
              actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-trash"></i>删除</a>');
              return actions.join('');
            } else {
              return "";
            }
          }
        }]
    };
    $.treeTable.init(options);
  });
</script>
</body>
</html>